<template>
  <div class="page-header" :class="{ emphasize: isEmphasize }">
    <div class="left">
      <div :class="{ 'img-box': !isEmphasize }" v-if="hasReturn">
        <img
          :src="
            isEmphasize
              ? require('@/assets/imgs/ic_lift@2x.png')
              : require('@/assets/imgs/order/ic_more@2x.png')
          "
          :class="{ img: !isEmphasize, ic_lift: isEmphasize }"
          @click="returnHandle"
        />
      </div>
      <div :class="{ 'img-box': !isEmphasize }" v-if="hasReturns">
        <img
          :src="
            isEmphasize
              ? require('@/assets/imgs/ic_lift@2x.png')
              : require('@/assets/imgs/order/ic_more@2x.png')
          "
          :class="{ img: !isEmphasize, ic_lift: isEmphasize }"
          @click="$emit('click')"
        />
      </div>

      <div class="title" :class="{ 'padding-left': hasReturn || hasReturns }">
        {{ title }}
      </div>
      <div class="content" v-if="content1">{{ content1 }}</div>
    </div>
    <div class="actions-box">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'page-header',
  props: {
    // 标题
    title: {
      type: String,
      default: ''
    },
    // 内容1
    content1: {
      type: String,
      default: ''
    },
    // 是否有返回按钮
    hasReturn: {
      type: Boolean,
      default: true
    },
    // 是否有返回按钮
    hasReturns: {
      type: Boolean,
      default: false
    },
    // 是否强调背景
    isEmphasize: {
      type: Boolean,
      default: false
    },
    // 跳转路由
    jumpPath: {
      type: String,
      default: ''
    }
  },
  data () {
    return {}
  },
  created () {},
  methods: {
    // 返回处理
    returnHandle () {
      // 组件中是否有传入跳转参数
      if (this.jumpPath) {
        this.jump(this.jumpPath)
      } else {
        // 路径上是否有jumpPath、jumpUrl跳转参数，存在则跳转
        if (this.$route.query.jumpPath) {
          this.jump(this.$route.query.jumpPath)
        } else if (this.$route.query.jumpUrl) {
          this.openUrl(this.$route.query.jumpUrl, '_self')
        } else {
          this.back()
        }
      }
    }
  }
}
</script>

<style scoped lang="scss">
.page-header {
  // width: calc(100% - #{$appLefterWidth});
  background-color: $backgroundColor;
  height: $pageHeaderHeight;
  z-index: 99;
  padding: 20px;
  padding-right: 12px;
  min-width: 1220px;
  // position: fixed;
  top: $appHeaderHeight;

  display: flex;
  justify-content: space-between;
  align-items: center;

  // & > div {
  //   width: 50%;
  // }

  .left {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    // height: 40px;

    .padding-left {
      padding-left: 12px;
    }

    .img-box {
      width: 36px;
      height: 36px;
      background: rgba(210, 216, 226, 0.14);
      border: 1px solid #d2d8e2;
      border-radius: 4px;

      display: flex;
      justify-content: center;
      align-items: center;

      & > img {
        width: 20px;
        height: 20px;
        cursor: pointer;
      }
    }

    .ic_lift {
      width: 36px;
      height: 36px;
      cursor: pointer;
    }

    .title {
      font-size: 23px;
      font-weight: 600;
      text-align: left;
      line-height: 28px;
      color: #39404d;
    }

    .content {
      height: 27px;
      display: flex;
      align-items: center;
      font-size: 14px;
      font-weight: 400;
      text-align: left;
      color: #646b80;
      line-height: 22px;
      margin-left: 20px;
    }
  }

  .actions-box {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    height: 40px;
    margin-right: 8px;
  }
}

.emphasize {
  background-color: $color !important;
  height: 96px;
  align-items: start;

  .left {
    .img-box {
      border: 1px solid #ffffff;
    }

    .title {
      color: #ffffff;
    }
  }
  .actions-box button {
    background-color: #ffffff;
    color: #3a404d;
    // width: 160px;
    height: 36px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    color: var(--text-color);
    line-height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.divTab {
  ::v-deep .el-tabs__header {
    margin: 0 0 10px !important;
  }
  // ::v-deep .el-tabs__item {
  //   height: 30px !important;
  //   line-height: 30px !important;
  // }
}
</style>
